package com.linkstec.mot.business.gtja;

import java.sql.Timestamp;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkstec.mot.business.IDealData;

/**
 * 
 * 
 *{"appendInformation":"金额=880000.00;日期=2017年03月09日;客户号=1633833;客户姓名=林媛媛","bcc":"",
 *"body":"bst://customer?custcode=1633833&custname=林媛媛","bodyFormat":"url","cc":"","channel":"inform", *"createTime":"2017-12-05 15:40:50:917",
 *"custId":"004422","custType":"1","email":"","ext1":"bstapp","ext2":"453","ext3":"khsbzjrz", *"isTop":"0",
 *"lateSendTime":"2017-12-05 21","mailFrom":"","messageSubType":"khsbzjrz","messageType":"SW","mobile":"", *"publishTime":"",
 *"subject":"首笔资金入账","summary":"您的客户林媛媛在2017年03月09日首笔资金转账成功，金额880000.00元","thirdSysId":"SMOT_43093867","url":""}
 * 
 * 
 * 
 * @author LYL
 * 
 */
public class ServiceMarksOper implements IDealData {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public Map<String, Object> dealData(Object data) {
		JSONObject result = JSON.parseObject((String) data);
		logger.info("收到一条消息：" + result);
		if (checkKafkaMsg(result)) {
			/*String pushContent = result.toJSONString();
			Date date = new Date();
			String bizDate = new SimpleDateFormat("yyyyMMdd").format(date);
			String startPushDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(date);
			//发送内容
			result.put("pushContent", pushContent);
			result.put("bizDate", bizDate);
			result.put("startPushDate", startPushDate);*/
			
			Long eventTrgTime = result.getLong("eventTrgTime");
			Timestamp date = new Timestamp(eventTrgTime);
			result.put("eventTrgTime", date);
			
		} else {
			result = null;
		}
		return result;
	}

	private boolean checkKafkaMsg(JSONObject result) {
		/*String providerId = result.getString("providerId");
		if (!"SMOT".equals(providerId)) {
			return false;
		}*/
		
		/*String eventId = result.getString("eventId");

		if (StringUtil.isNullOrEmpty(eventId)) {
			logger.info(">>>>>>>>>>>eventId为空");
			return false;
		}*/
		return true;
	}
}